#!/usr/bin/env tclsh

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Tolerance for floating point comparisons
# FIXME: When Limbo's floating point presentation matches to SQLite, this could/should be removed
set tolerance 1e-13

do_execsql_test add-int {
  SELECT 10 + 1
} {11}

do_execsql_test add-float {
  SELECT 10.1 + 0.3
} {10.4}

do_execsql_test add-int-float {
  SELECT 10 + 0.1
} {10.1}

do_execsql_test add-agg-int-agg-int {
  SELECT sum(1) + sum(2)
} {3}

do_execsql_test add-agg-int-agg-float {
  SELECT sum(1) + sum(2.5)
} {3.5}

do_execsql_test add-agg-float-agg-int {
  SELECT sum(1.5) + sum(2)
} {3.5}

do_execsql_test subtract-int {
  SELECT 10 - 1
} {9}

do_execsql_test subtract-float {
  SELECT 10.2 - 0.1
} {10.1}

do_execsql_test subtract-int-float {
  SELECT 10 - 0.1
} {9.9}

do_execsql_test subtract-agg-int-agg-int {
  SELECT sum(3) - sum(1)
} {2}

do_execsql_test subtract-agg-int-agg-float {
  SELECT sum(3) - sum(1.5)
} {1.5}

do_execsql_test subtract-agg-float-agg-int {
  SELECT sum(3.5) - sum(1)
} {2.5}

do_execsql_test multiply-int {
  SELECT 10 * 2
} {20}

do_execsql_test multiply-float {
  SELECT 10.2 * 2.2
} {22.44}

do_execsql_test multiply-int-float {
  SELECT 10 * 1.45
} {14.5}

do_execsql_test multiply-float-int {
  SELECT 1.45 * 10
} {14.5}

do_execsql_test multiply-agg-int-agg-int {
  SELECT sum(2) * sum(3)
} {6}

do_execsql_test multiply-agg-int-agg-float {
  SELECT sum(2) * sum(3.5)
} {7.0}

do_execsql_test multiply-agg-float-agg-int {
  SELECT sum(2.5) * sum(3)
} {7.5}

do_execsql_test divide-int {
  SELECT 10 / 2
} {5}

do_execsql_test divide-int-no-fraction {
  SELECT 10 / 3
} {3}

do_execsql_test divide-float {
  SELECT 10.6 / 2.5
} {4.24}

do_execsql_test divide-int-float {
  SELECT 10 / 4.0
} {2.5}

do_execsql_test divide-float-int {
  SELECT 10.0 / 4
} {2.5}

do_execsql_test divide-by-zero {
  SELECT 10 / 0
} {}

do_execsql_test divide-int-null {
  SELECT 10 / null
} {}

do_execsql_test divide-null-int {
  SELECT null / 10
} {}

do_execsql_test divide-null {
  SELECT null / null
} {}

do_execsql_test divide-agg-int-agg-int {
  SELECT sum(4) / sum(2)
} {2}

do_execsql_test divide-agg-int-agg-float {
  SELECT sum(4) / sum(2.0)
} {2.0}

do_execsql_test divide-agg-float-agg-int {
  SELECT sum(4.0) / sum(2)
} {2.0}


do_execsql_test add-agg-int {
  SELECT sum(id) + 10 from products
} {76}

do_execsql_test add-int-agg {
  SELECT 10 + sum(id) from products
} {76}

do_execsql_test add-agg-float {
  SELECT sum(id) + 10.1 from products
} {76.1}

do_execsql_test add-float-agg {
  SELECT 10.1 + sum(id) from products
} {76.1}

do_execsql_test add-agg-int-agg-int {
  SELECT sum(id) + sum(id) from products
} {132}

do_execsql_test add-agg-float-agg-float {
  SELECT sum(price) + sum(price) from products
} {1246.0}

do_execsql_test add-agg-int-agg-float {
  SELECT sum(id) + sum(price) from products
} {689.0}

do_execsql_test add-agg-int-agg-float {
  SELECT sum(id) + sum(price) from products
} {689.0}



do_execsql_test subtract-agg-int {
  SELECT sum(id) - 10 from products
} {56}

do_execsql_test subtract-int-agg {
  SELECT 10 - sum(id) from products
} {-56}

do_execsql_test subtract-agg-float {
  SELECT sum(id) - 10.1 from products
} {55.9}

do_execsql_test subtract-float-agg {
  SELECT 10.1 - sum(id) from products
} {-55.9}

do_execsql_test subtract-agg-int-agg-int {
  SELECT sum(id) - sum(id) from products
} {0}

do_execsql_test subtract-agg-float-agg-float {
  SELECT sum(price) - sum(price) from products
} {0.0}

do_execsql_test subtract-agg-int-agg-float {
  SELECT sum(id) - sum(price) from products
} {-557.0}

do_execsql_test subtract-agg-float-agg-int {
  SELECT sum(price) - sum(id) from products
} {557.0}



do_execsql_test multiply-agg-int {
  SELECT sum(id) * 10 from products
} {660}

do_execsql_test multiply-int-agg {
  SELECT 10 * sum(id) from products
} {660}

do_execsql_test multiply-agg-float {
  SELECT sum(id) * 10.1 from products
} {666.6}

do_execsql_test multiply-float-agg {
  SELECT 10.1 * sum(id) from products
} {666.6}

do_execsql_test multiply-agg-int-agg-int {
  SELECT sum(id) * sum(id) from products
} {4356}

do_execsql_test multiply-agg-float-agg-float {
  SELECT sum(price) * sum(price) from products
} {388129.0}

do_execsql_test multiply-agg-int-agg-float {
  SELECT sum(id) * sum(price) from products
} {41118.0}

do_execsql_test multiply-agg-float-agg-int {
  SELECT sum(price) * sum(id) from products
} {41118.0}



do_execsql_test divide-agg-int {
  SELECT sum(id) / 10 from products
} {6}

do_execsql_test divide-int-agg {
  SELECT 660 / sum(id) from products
} {10}

do_execsql_test divide-agg-float {
  SELECT sum(id) / 1.5 from products
} {44.0}

do_execsql_test divide-float-agg {
  SELECT 66.0 / sum(id) from products
} {1.0}

do_execsql_test divide-agg-int-agg-int {
  SELECT sum(id) / sum(id) from products
} {1}

do_execsql_test divide-agg-float-agg-float {
  SELECT sum(price) / sum(price) from products
} {1.0}

do_execsql_test divide-agg-int-agg-float {
  SELECT sum(id) / min(price) from products
} {66.0}

do_execsql_test divide-agg-float-agg-int {
  SELECT min(price) / min(id) from products
} {1.0}


do_execsql_test bitwise-and-int-null {
  SELECT 1234 & NULL
} {}

do_execsql_test bitwise-and-int-int {
  SELECT 1234 & 1234
} {1234}

do_execsql_test bitwise-and-int-float {
  SELECT 660 & 261.8
} {4}

do_execsql_test bitwise-and-float-float {
  SELECT 660.63 & 261.8
} {4}

do_execsql_test bitwise-and-float-int-rev {
  SELECT 261.8 & 660
} {4}

do_execsql_test bitwise-and-int-agg-int {
   SELECT 8261 & sum(id) from products
} {64}

do_execsql_test bitwise-and-int-agg-float {
    SELECT 1036.6 & sum(id) from products
} {0}

do_execsql_test bitwise-and-int-agg-int-agg {
    SELECT sum(id) & sum(id) from products
} {66}


do_execsql_test bitwise-or-int-null {
    SELECT 1234 | NULL
} {}

do_execsql_test bitwise-or-null-int {
    SELECT NULL | 1234
} {}

do_execsql_test bitwise-or-int-int {
    SELECT 4321 | 1234
} {5363}

do_execsql_test bitwise-or-int-float {
    SELECT 660 | 1234.0
} {1750}

do_execsql_test bitwise-or-int-agg {
    SELECT 18823 | sum(id) from products
} {18887}

do_execsql_test bitwise-or-float-float {
    SELECT 1234.6 | 5432.2
} {5626}

do_execsql_test bitwise-and-int-agg-int-agg {
    SELECT sum(id) | sum(id) from products
} {66}


do_execsql_test bitwise-not-null {
	SELECT ~NULL
} {}

do_execsql_test bitwise-not-int {
	SELECT ~1234
} {-1235}

do_execsql_test bitwise-not-float {
	SELECT ~823.34
} {-824}

do_execsql_test bitwise-not-scalar-float {
	SELECT ~abs(693.9)
} {-694}

do_execsql_test bitwise-not-scalar-int {
	SELECT ~abs(7566)
} {-7567}

do_execsql_test bitwise-not-agg-int {
	SELECT ~sum(693)
} {-694}

do_execsql_test bitwise-not-agg-and-agg {
	SELECT ~sum(693) & sum(-302)
} {-958}

do_execsql_test bitwise-not-agg-int {
	SELECT ~sum(693)
} {-694}

do_execsql_test bitwise-not-zero {
	SELECT ~0
} {-1}


do_execsql_test_tolerance pi {
  SELECT pi()
} {3.14159265358979} $tolerance


do_execsql_test_tolerance acos-int {
  SELECT acos(1)
} {0.0} $tolerance

do_execsql_test_tolerance acos-float {
  SELECT acos(-0.5)
} {2.0943951023931957} $tolerance

do_execsql_test_tolerance acos-str {
  SELECT acos('-0.5')
} {2.0943951023931957} $tolerance

do_execsql_test_tolerance acos-null {
  SELECT acos(null)
} {} $tolerance


do_execsql_test_tolerance acosh-int {
  SELECT acosh(1)
} {0.0} $tolerance

do_execsql_test_tolerance acosh-float {
  SELECT acosh(1.5)
} {0.962423650119207} $tolerance

do_execsql_test_tolerance acosh-str {
  SELECT acosh('1.5')
} {0.962423650119207} $tolerance

do_execsql_test_tolerance acosh-invalid {
  SELECT acosh(0.99)
} {} $tolerance

do_execsql_test_tolerance acosh-null {
  SELECT acosh(null)
} {} $tolerance


do_execsql_test_tolerance asin-int {
  SELECT asin(1)
} {1.5707963267948966} $tolerance

do_execsql_test_tolerance asin-float {
  SELECT asin(-0.5)
} {-0.5235987755982989} $tolerance

do_execsql_test_tolerance asin-str {
  SELECT asin('-0.5')
} {-0.5235987755982989} $tolerance

do_execsql_test_tolerance asin-null {
  SELECT asin(null)
} {} $tolerance


do_execsql_test_tolerance sin-int {
  SELECT sin(1)
} {0.841470984807897} $tolerance

do_execsql_test_tolerance sin-float {
  SELECT sin(-0.5)
} {-0.479425538604203} $tolerance

do_execsql_test_tolerance sin-str {
  SELECT sin('-0.5')
} {-0.479425538604203} $tolerance

do_execsql_test_tolerance sin-null {
  SELECT sin(null)
} {} $tolerance

do_execsql_test_tolerance sin-products-id {
  SELECT sin(id) from products limit 5
} {0.8414709848078965
0.9092974268256817
0.1411200080598672
-0.7568024953079282
-0.9589242746631385} $tolerance


do_execsql_test_tolerance asinh-int {
  SELECT asinh(1)
} {0.881373587019543} $tolerance

do_execsql_test_tolerance asinh-float {
  SELECT asinh(-0.5)
} {-0.48121182505960347} $tolerance

do_execsql_test_tolerance asinh-str {
  SELECT asinh('-0.5')
} {-0.48121182505960347} $tolerance

do_execsql_test_tolerance asinh-null {
  SELECT asinh(null)
} {} $tolerance


do_execsql_test_tolerance atan-int {
  SELECT atan(1)
} {0.7853981633974483} $tolerance

do_execsql_test_tolerance atan-float {
  SELECT atan(-0.5)
} {-0.4636476090008061} $tolerance

do_execsql_test_tolerance atan-str {
  SELECT atan('-0.5')
} {-0.4636476090008061} $tolerance

do_execsql_test_tolerance atan-null {
  SELECT atan(null)
} {} $tolerance


do_execsql_test_tolerance tan-int {
  SELECT tan(1)
} {1.5574077246549} $tolerance

do_execsql_test_tolerance tan-float {
  SELECT tan(-0.5)
} {-0.54630248984379} $tolerance

do_execsql_test_tolerance tan-str {
  SELECT tan('-0.5')
} {-0.54630248984379} $tolerance

do_execsql_test_tolerance tan-null {
  SELECT tan(null)
} {} $tolerance


do_execsql_test_tolerance atanh-int {
  SELECT atanh(0)
} {0.0} $tolerance

do_execsql_test_tolerance atanh-float {
  SELECT atanh(-0.5)
} {-0.5493061443340548} $tolerance

do_execsql_test_tolerance atanh-str {
  SELECT atanh('-0.5')
} {-0.5493061443340548} $tolerance

do_execsql_test_tolerance atanh-null {
  SELECT atanh(null)
} {} $tolerance


do_execsql_test ceil-int {
  SELECT ceil(1)
} {1}

do_execsql_test ceil-float {
  SELECT ceil(-1.5)
} {-1.0}

do_execsql_test ceil-str {
  SELECT ceil('1.5')
} {2.0}

do_execsql_test ceil-null {
  SELECT ceil(null)
} {}


do_execsql_test ceiling-int {
  SELECT ceiling(1)
} {1}

do_execsql_test ceiling-float {
  SELECT ceiling(-1.5)
} {-1.0}

do_execsql_test ceiling-str {
  SELECT ceiling('1.5')
} {2.0}

do_execsql_test ceiling-null {
  SELECT ceiling(null)
} {}


do_execsql_test_tolerance cos-int {
  SELECT cos(1)
} {0.54030230586814} $tolerance

do_execsql_test_tolerance cos-float {
  SELECT cos(-0.5)
} {0.877582561890373} $tolerance

do_execsql_test_tolerance cos-str {
  SELECT cos('-0.5')
} {0.877582561890373} $tolerance

do_execsql_test_tolerance cos-null {
  SELECT cos(null)
} {} $tolerance


do_execsql_test_tolerance cosh-int {
  SELECT cosh(1)
} {1.54308063481524} $tolerance

do_execsql_test_tolerance cosh-float {
  SELECT cosh(-0.5)
} {1.12762596520638} $tolerance

do_execsql_test_tolerance cosh-str {
  SELECT cosh('-0.5')
} {1.12762596520638} $tolerance

do_execsql_test_tolerance cosh-null {
  SELECT cosh(null)
} {} $tolerance


do_execsql_test_tolerance degrees-int {
  SELECT degrees(1)
} {57.2957795130823} $tolerance

do_execsql_test_tolerance degrees-float {
  SELECT degrees(-0.5)
} {-28.6478897565412} $tolerance

do_execsql_test_tolerance degrees-str {
  SELECT degrees('-0.5')
} {-28.6478897565412} $tolerance

do_execsql_test_tolerance degrees-null {
  SELECT degrees(null)
} {} $tolerance


do_execsql_test_tolerance exp-int {
  SELECT exp(1)
} {2.71828182845905} $tolerance

do_execsql_test_tolerance exp-float {
  SELECT exp(-0.5)
} {0.606530659712633} $tolerance

do_execsql_test_tolerance exp-str {
  SELECT exp('-0.5')
} {0.606530659712633} $tolerance

do_execsql_test_tolerance exp-null {
  SELECT exp(null)
} {} $tolerance


do_execsql_test floor-int {
  SELECT floor(1)
} {1}

do_execsql_test floor-float {
  SELECT floor(-1.5)
} {-2.0}

do_execsql_test floor-str {
  SELECT floor('1.5')
} {1.0}

do_execsql_test floor-null {
  SELECT floor(null)
} {}


do_execsql_test_tolerance ln-int {
  SELECT ln(1)
} {0.0} $tolerance

do_execsql_test_tolerance ln-float {
  SELECT ln(0.5)
} {-0.693147180559945} $tolerance

do_execsql_test_tolerance ln-str {
  SELECT ln('0.5')
} {-0.693147180559945} $tolerance

do_execsql_test_tolerance ln-negative {
  SELECT ln(-0.5)
} {} $tolerance

do_execsql_test_tolerance ln-null {
  SELECT ln(null)
} {} $tolerance


do_execsql_test_tolerance log10-int {
  SELECT log10(1)
} {0.0} $tolerance

do_execsql_test_tolerance log10-float {
  SELECT log10(0.5)
} {-0.301029995663981} $tolerance

do_execsql_test_tolerance log10-str {
  SELECT log10('0.5')
} {-0.301029995663981} $tolerance

do_execsql_test_tolerance log10-negative {
  SELECT log10(-0.5)
} {} $tolerance

do_execsql_test_tolerance log10-null {
  SELECT log10(null)
} {} $tolerance


do_execsql_test_tolerance log2-int {
  SELECT log2(1)
} {0.0} $tolerance

do_execsql_test_tolerance log2-float {
  SELECT log2(0.5)
} {-1.0} $tolerance

do_execsql_test_tolerance log2-str {
  SELECT log2('0.5')
} {-1.0} $tolerance

do_execsql_test_tolerance log2-negative {
  SELECT log2(-0.5)
} {} $tolerance

do_execsql_test_tolerance log2-null {
  SELECT log2(null)
} {} $tolerance


do_execsql_test_tolerance radians-int {
  SELECT radians(1)
} {0.0174532925199433} $tolerance

do_execsql_test_tolerance radians-float {
  SELECT radians(-0.5)
} {-0.00872664625997165} $tolerance

do_execsql_test_tolerance radians-str {
  SELECT radians('-0.5')
} {-0.00872664625997165} $tolerance

do_execsql_test_tolerance radians-null {
  SELECT radians(null)
} {} $tolerance


do_execsql_test_tolerance sinh-int {
  SELECT sinh(1)
} {1.1752011936438} $tolerance

do_execsql_test_tolerance sinh-float {
  SELECT sinh(-0.5)
} {-0.521095305493747} $tolerance

do_execsql_test_tolerance sinh-str {
  SELECT sinh('-0.5')
} {-0.521095305493747} $tolerance

do_execsql_test_tolerance sinh-null {
  SELECT sinh(null)
} {} $tolerance


do_execsql_test_tolerance sqrt-int {
  SELECT sqrt(1)
} {1.0} $tolerance

do_execsql_test_tolerance sqrt-float {
  SELECT sqrt(0.5)
} {0.707106781186548} $tolerance

do_execsql_test_tolerance sqrt-str {
  SELECT sqrt('0.5')
} {0.707106781186548} $tolerance

do_execsql_test_tolerance sqrt-negative {
  SELECT sqrt(-0.5)
} {} $tolerance

do_execsql_test_tolerance sqrt-null {
  SELECT sqrt(null)
} {} $tolerance


do_execsql_test_tolerance tanh-int {
  SELECT tanh(1)
} {0.761594155955765} $tolerance

do_execsql_test_tolerance tanh-float {
  SELECT tanh(-0.5)
} {-0.46211715726001} $tolerance

do_execsql_test_tolerance tanh-str {
  SELECT tanh('-0.5')
} {-0.46211715726001} $tolerance

do_execsql_test_tolerance tanh-null {
  SELECT tanh(null)
} {} $tolerance


do_execsql_test trunc-int {
  SELECT trunc(1)
} {1}

do_execsql_test trunc-float {
  SELECT trunc(2.5)
} {2.0}

do_execsql_test trunc-float-negative {
  SELECT trunc(-2.5)
} {-2.0}

do_execsql_test trunc-str {
  SELECT trunc('2.5')
} {2.0}

do_execsql_test trunc-null {
  SELECT trunc(null)
} {}


do_execsql_test_tolerance atan2-int-int {
  SELECT atan2(5, -1)
} {1.76819188664478} $tolerance

do_execsql_test_tolerance atan2-int-float {
  SELECT atan2(5, -1.5)
} {1.86225312127276} $tolerance

do_execsql_test_tolerance atan2-int-str {
  SELECT atan2(5, '-1.5')
} {1.86225312127276} $tolerance

do_execsql_test_tolerance atan2-float-int {
  SELECT atan2(5.5, 10)
} {0.502843210927861} $tolerance

do_execsql_test_tolerance atan2-float-float {
  SELECT atan2(5.5, -1.5)
} {1.83704837594582} $tolerance

do_execsql_test_tolerance atan2-float-str {
  SELECT atan2(5.5, '-1.5')
} {1.83704837594582} $tolerance

do_execsql_test_tolerance atan2-str-str {
  SELECT atan2('5.5', '-1.5')
} {1.83704837594582} $tolerance

do_execsql_test atan2-null-int {
  SELECT atan2(null, 5)
} {}

do_execsql_test atan2-int-null {
  SELECT atan2(5, null)
} {}


do_execsql_test_tolerance mod-int-int {
  SELECT mod(10, -3)
} {1.0} $tolerance

do_execsql_test_tolerance mod-int-float {
  SELECT mod(5, -1.5)
} {0.5} $tolerance

do_execsql_test_tolerance mod-int-str {
  SELECT mod(5, '-1.5')
} {0.5} $tolerance

do_execsql_test_tolerance mod-float-int {
  SELECT mod(5.5, 2)
} {1.5} $tolerance

do_execsql_test_tolerance mod-float-float {
  SELECT mod(5.5, -1.5)
} {1.0} $tolerance

do_execsql_test_tolerance mod-float-str {
  SELECT mod(5.5, '-1.5')
} {1.0} $tolerance

do_execsql_test_tolerance mod-str-str {
  SELECT mod('5.5', '-1.5')
} {1.0} $tolerance

do_execsql_test mod-null-int {
  SELECT mod(null, 5)
} {}

do_execsql_test mod-int-null {
  SELECT mod(5, null)
} {}

do_execsql_test mod-float-zero {
  SELECT mod(1.5, 0)
} {}

do_execsql_test mod-products-id {
  SELECT mod(products.id, 3) from products limit 5
} {1.0
2.0
0.0
1.0
2.0}

do_execsql_test mod-products-price-id {
  SELECT mod(products.price, products.id) from products limit 5
} {0.0
0.0
0.0
1.0
4.0}


do_execsql_test_tolerance pow-int-int {
  SELECT pow(5, -1)
} {0.2} $tolerance

do_execsql_test_tolerance pow-int-float {
  SELECT pow(5, -1.5)
} {0.0894427190999916} $tolerance

do_execsql_test_tolerance pow-int-str {
  SELECT pow(5, '-1.5')
} {0.0894427190999916} $tolerance

do_execsql_test_tolerance pow-float-int {
  SELECT pow(5.5, 2)
} {30.25} $tolerance

do_execsql_test_tolerance pow-float-float {
  SELECT pow(5.5, -1.5)
} {0.077527533220222} $tolerance

do_execsql_test_tolerance pow-float-str {
  SELECT pow(5.5, '-1.5')
} {0.077527533220222} $tolerance

do_execsql_test_tolerance pow-str-str {
  SELECT pow('5.5', '-1.5')
} {0.077527533220222} $tolerance

do_execsql_test pow-null-int {
  SELECT pow(null, 5)
} {}

do_execsql_test pow-int-null {
  SELECT pow(5, null)
} {}


do_execsql_test_tolerance power-int-int {
  SELECT power(5, -1)
} {0.2} $tolerance

do_execsql_test_tolerance power-int-float {
  SELECT power(5, -1.5)
} {0.0894427190999916} $tolerance

do_execsql_test_tolerance power-int-str {
  SELECT power(5, '-1.5')
} {0.0894427190999916} $tolerance

do_execsql_test_tolerance power-float-int {
  SELECT power(5.5, 2)
} {30.25} $tolerance

do_execsql_test_tolerance power-float-float {
  SELECT power(5.5, -1.5)
} {0.077527533220222} $tolerance

do_execsql_test_tolerance power-float-str {
  SELECT power(5.5, '-1.5')
} {0.077527533220222} $tolerance

do_execsql_test_tolerance power-str-str {
  SELECT power('5.5', '-1.5')
} {0.077527533220222} $tolerance

do_execsql_test power-null-int {
  SELECT power(null, 5)
} {}

do_execsql_test power-int-null {
  SELECT power(5, null)
} {}


do_execsql_test_tolerance log-int {
  SELECT log(1)
} {0.0} $tolerance

do_execsql_test_tolerance log-float {
  SELECT log(1.5)
} {0.176091259055681} $tolerance

do_execsql_test_tolerance log-str {
  SELECT log('1.5')
} {0.176091259055681} $tolerance

do_execsql_test log-negative {
  SELECT log(-1.5)
} {}

do_execsql_test log-null {
  SELECT log(null)
} {}

do_execsql_test_tolerance log-int-int {
  SELECT log(5, 1)
} {0.0} $tolerance

do_execsql_test_tolerance log-int-float {
  SELECT log(5, 1.5)
} {0.251929636412592} $tolerance

do_execsql_test_tolerance log-int-str {
  SELECT log(5, '1.5')
} {0.251929636412592} $tolerance

do_execsql_test_tolerance log-float-int {
  SELECT log(5.5, 10)
} {1.35068935021985} $tolerance

do_execsql_test_tolerance log-float-float {
  SELECT log(5.5, 1.5)
} {0.237844588273313} $tolerance

do_execsql_test_tolerance log-float-str {
  SELECT log(5.5, '1.5')
} {0.237844588273313} $tolerance

do_execsql_test_tolerance log-str-str {
  SELECT log('5.5', '1.5')
} {0.237844588273313} $tolerance

do_execsql_test log-negative-negative {
  SELECT log(-1.5, -1.5)
} {}

do_execsql_test log-float-negative {
  SELECT log(1.5, -1.5)
} {}

do_execsql_test log-null-int {
  SELECT log(null, 5)
} {}

do_execsql_test log-int-null {
  SELECT log(5, null)
} {}
